/* This header file is part of the ATMEL AVR32-SoftwareFramework-AT32UC3A-1.4.0 Release */

/*This file is prepared for Doxygen automatic documentation generation.*/
/*! \file *********************************************************************
 *
 * \brief Standard board header file.
 *
 * This file includes the appropriate board header file according to the
 * defined board.
 *
 * - Compiler:           IAR EWAVR32 and GNU GCC for AVR32
 * - Supported devices:  All AVR32 devices can be used.
 * - AppNote:
 *
 * \author               Atmel Corporation: http://www.atmel.com \n
 *                       Support and FAQ: http://support.atmel.no/
 *
 ******************************************************************************/

/* Copyright (C) 2006-2008, Atmel Corporation All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * 3. The name of ATMEL may not be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


#ifndef _BOARD_H_
#define _BOARD_H_

#include <avr32/io.h>
#include "drivers/compiler.h"

#define PORTB 0x20


#define FOSC0           48000000                              //!< Osc0 frequency: Hz.
#define OSC0_STARTUP    AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC  //!< Osc0 startup time: RCOsc periods.
#define CP_PBA_SPEED    FOSC0/2

#define configDBG	1
//! Number of LEDs.
#define LED_COUNT   8

/*! \name GPIO Connections of LED */

#define LED0					AVR32_PIN_PB19
#define LED1					AVR32_PIN_PB20
#define LED2					AVR32_PIN_PB21
#define LED3					AVR32_PIN_PB22

#define CAPTEURS	LASER
/*
	#define CAPTEUR_GAUCHE			AVR32_PIN_PA22
	#define ETAT_CAPTEUR_GAUCHE		gpio_get_pin_value(CAPTEUR_GAUCHE)
	#define CAPTEUR_DROIT			AVR32_PIN_PA21
	#define ETAT_CAPTEUR_DROIT		gpio_get_pin_value(CAPTEUR_DROIT)
	#define CAPTEUR_CENTRE			AVR32_PIN_PA23
	#define ETAT_CAPTEUR_CENTRE		gpio_get_pin_value(CAPTEUR_CENTRE)
*/
	#define CAPTEUR_LASER_GAUCHE_EXT 	AVR32_PIN_PA24
	#define ETAT_CAPTEUR_GAUCHE_EXT		gpio_get_pin_value(CAPTEUR_LASER_GAUCHE_EXT)
	#define CAPTEUR_LASER_GAUCHE 		AVR32_PIN_PA25
	#define ETAT_CAPTEUR_GAUCHE			gpio_get_pin_value(CAPTEUR_LASER_GAUCHE)
	#define CAPTEUR_LASER_CENTRE		AVR32_PIN_PA26
	#define ETAT_CAPTEUR_CENTRE			gpio_get_pin_value(CAPTEUR_LASER_CENTRE)
	#define CAPTEUR_LASER_DROIT 		AVR32_PIN_PA27
	#define ETAT_CAPTEUR_DROIT			gpio_get_pin_value(CAPTEUR_LASER_DROIT)
	#define CAPTEUR_LASER_DROITE_EXT 	AVR32_PIN_PA28
	#define ETAT_CAPTEUR_DROITE_EXT		gpio_get_pin_value(CAPTEUR_LASER_DROITE_EXT)
	#define CAPTEUR_LASER_LED			AVR32_PIN_PA29

#define NOIR 					1
#define BLANC					0

#define CAPTEUR_ADC_CHANNEL     0
#define CAPTEUR_ADC_PIN         AVR32_ADC_AD_0_PIN
#define CAPTEUR_ADC_FUNCTION    AVR32_ADC_AD_0_FUNCTION


#define PI					3.1416
#define VRAI					1
#define FAUX					0

#define RAD2DEG                                 (180.0/M_PI)

#define LED_RX		AVR32_PIN_PB19
#define LED_TX		AVR32_PIN_PB20

#define configDBG_USART_RX_PIN			AVR32_USART0_RXD_0_0_PIN
#define configDBG_USART_RX_FUNCTION		AVR32_USART0_RXD_0_0_FUNCTION
#define configDBG_USART_TX_PIN			AVR32_USART0_TXD_0_0_PIN
#define configDBG_USART_TX_FUNCTION		AVR32_USART0_TXD_0_0_FUNCTION
#define configDBG_USART_BAUDRATE		38400
#define configDBG_USART					&(AVR32_USART0)

#define RUPTEUR_GAUCHE					AVR32_PIN_PA22
#define RUPTEUR_DROIT					AVR32_PIN_PA23

#define GET_RUPTEUR_GAUCHE()			!gpio_get_pin_value(RUPTEUR_GAUCHE)
#define GET_RUPTEUR_DROIT()				!gpio_get_pin_value(RUPTEUR_DROIT)

//! @}


#ifndef FRCOSC
  #define FRCOSC    AVR32_PM_RCOSC_FREQUENCY  //!< Default RCOsc frequency.
#endif
#define WELCOME		"\x1B[2J\x1B[;H#"

#define WELCOME20		"\x1B[2J\x1B[;H\
#######################################################\r\n\
#######################################################\r\n\
@@@                                                 @@@\r\n\
@@@       /####  #####    #########    /#######     @@@\r\n\
@@@      ###     ##  ##   #########   ###           @@@\r\n\
@@@     @#       ##   ##     ##      ###            @@@\r\n\
@@@    ##        ##  ##      ##        ##           @@@\r\n\
@@@    ##        ## ##       ##         ####        @@@\r\n\
@@@    ##        #####       ##            ####     @@@\r\n\
@@@    ##        ## ###      ##               ##    @@@\r\n"
#define WELCOME21 	"\
@@@     @#       ##  ##      ##               ##    @@@\r\n\
@@@      ###     ##   ##  #########      ######     @@@\r\n\
@@@      \\####   ##    ## #########   #######       @@@\r\n\
@@@                                                 @@@\r\n\
@@@      Club   Robotique   Insa     Strasbourg     @@@\r\n\
@@@                                                 @@@\r\n\
#######################################################\r\n\
#######################################################\r\n"

/*! \name VT100 Common Commands
 */
//! @{
#define CLEARSCR          "\x1B[2J\x1B[;H"    //!< Clear screen.
#define CLEAREOL          "\x1B[K"            //!< Clear end of line.
#define CLEAREOS          "\x1B[J"            //!< Clear end of screen.
#define CLEARLCR          "\x1B[0K"           //!< Clear line cursor right.
#define CLEARLCL          "\x1B[1K"           //!< Clear line cursor left.
#define CLEARELN          "\x1B[2K"           //!< Clear entire line.
#define CLEARCDW          "\x1B[0J"           //!< Clear cursor down.
#define CLEARCUP          "\x1B[1J"           //!< Clear cursor up.
#define GOTOYX            "\x1B[%.2d;%.2dH"   //!< Set cursor to (y, x).
#define INSERTMOD         "\x1B[4h"           //!< Insert mode.
#define OVERWRITEMOD      "\x1B[4l"           //!< Overwrite mode.
#define DELAFCURSOR       "\x1B[K"            //!< Erase from cursor to end of line.
#define CRLF              "\r\n"              //!< Carriage Return + Line Feed.
//! @}

/*! \name VT100 Cursor Commands
 */
//! @{

#define CURSON            "\x1B[?25h"         //!< Show cursor.
#define CURSOFF           "\x1B[?25l"         //!< Hide cursor.

//! @}



/*! \name VT100 Character Commands
 */
//! @{
#define NORMAL            "\x1B[0m"           //!< Normal.
#define BOLD              "\x1B[1m"           //!< Bold.
#define UNDERLINE         "\x1B[4m"           //!< Underline.
#define BLINKING          "\x1B[5m"           //!< Blink.
#define INVVIDEO          "\x1B[7m"           //!< Inverse video.
//! @}



/*! \name VT100 Color Commands
 */
//! @{

#define CL_BLACK          "\033[22;30m"       //!< Black.
#define CL_RED            "\033[22;31m"       //!< Red.
#define CL_GREEN          "\033[22;32m"       //!< Green.
#define CL_BROWN          "\033[22;33m"       //!< Brown.
#define CL_BLUE           "\033[22;34m"       //!< Blue.
#define CL_MAGENTA        "\033[22;35m"       //!< Magenta.
#define CL_CYAN           "\033[22;36m"       //!< Cyan.
#define CL_GRAY           "\033[22;37m"       //!< Gray.
#define CL_DARKGRAY       "\033[01;30m"       //!< Dark gray.
#define CL_LIGHTRED       "\033[01;31m"       //!< Light red.
#define CL_LIGHTGREEN     "\033[01;32m"       //!< Light green.
#define CL_YELLOW         "\033[01;33m"       //!< Yellow.
#define CL_LIGHTBLUE      "\033[01;34m"       //!< Light blue.
#define CL_LIGHTMAGENTA   "\033[01;35m"       //!< Light magenta.
#define CL_LIGHTCYAN      "\033[01;36m"       //!< Light cyan.
#define CL_WHITE          "\033[01;37m"       //!< White.
//! @}


#endif  // _BOARD_H_
